package demo6;

public class test1 {
    public static void main(String[] args) {
        String qq = "123456789";

        System.out.println(qq.matches("[1-9]\\d{5,19}"));

        //是否为abc中的一个，只能对应一个字符，多个字符不行，需要能对应数量的判断条件
        System.out.println("===================1=============");
        System.out.println("a".matches("[abc]"));
        System.out.println("z".matches("[abc]"));
        System.out.println("ab".matches("[abc]"));
        System.out.println("ab".matches("[abc][abc]"));

        //除了abc
        System.out.println("===================2===============");
        System.out.println("a".matches("[^abc]"));
        System.out.println("z".matches("[^abc]"));
        System.out.println("zz".matches("[^abc]"));
        System.out.println("zz".matches("[^abc]"));

        //a-z 和 A-Z
        System.out.println("===================3==================");
        System.out.println("a".matches("[a-zA-Z]"));
        System.out.println("z".matches("[a-zA-Z]"));
        System.out.println("aa".matches("[a-zA-Z]"));
        System.out.println("zz".matches("[a-zA-Z]"));
        System.out.println("0".matches("[a-zA-Z]"));
        System.out.println("0".matches("[0-9]"));


        //a-d 或 m-p
        System.out.println("=====================4=====================");
        System.out.println("a".matches("[a-d[m-p]]"));
        System.out.println("d".matches("[a-d[m-p]]"));
        System.out.println("m".matches("[a-d[m-p]]"));
        System.out.println("p".matches("[a-d[m-p]]"));
        System.out.println("e".matches("[a-d[m-p]]"));
        System.out.println("0".matches("[a-d[m-p]]"));

        //[a-z&&[def]] a-z和def的交集：为d,e,f
        System.out.println("=================5=================");
        System.out.println("a".matches("[a-z&&[def]]"));
        System.out.println("d".matches("[a-z&&[def]]"));
        System.out.println("0".matches("[a-z&&[def]]"));

        //a-z和非bc的交集
        System.out.println("0".matches("[a-z&&[def]]"));
        System.out.println("0".matches("[a-z&&[def]]"));
        System.out.println("0".matches("[a-z&&[def]]"));


        // \表示转义字符
        //所以 \\ 表示一个普通的\

        //.表示任意一个字符
        System.out.println("你".matches(".."));
        System.out.println("你".matches("."));
        System.out.println("你好".matches(".."));

        // \\d表示任意的一位单位数字
        System.out.println("a".matches("\\d"));
        System.out.println("3".matches("\\d"));
        System.out.println("333".matches("\\d"));
        System.out.println("333".matches("\\d\\d\\d"));

        // \\w只能是一位单位字符 a-zA-Z_0-9
        System.out.println("z".matches("\\w"));
        System.out.println("2".matches("\\w"));
        System.out.println("21".matches("\\w"));
        System.out.println("你".matches("\\w"));
        System.out.println("_".matches("\\w"));

        //非单位字符
        System.out.println("你".matches("\\w"));
        System.out.println("=============================");
        //以上的正则匹配只能校验单个字符

        //必须是数字 字母 下划线 至少 6位
        System.out.println("2442fsfsf".matches("\\w{6,}"));
        System.out.println("244f".matches("\\w{6,}"));

        //
   }
}
